
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
vue-fragment
Advanced tools
a very candide fragment component for Vue.js
If you arrived here, I think you searched hard and you know why you're here.
For others, fragments are basically root-less components. They come useful in many situations where you don't want to pollute the DOM with a useless container, or you want to return many elements at once.
It's impossible to use functional components or slots, since Vue.js vDOM diffing has a "you should return one root element" limitation… Instead, I'm using an (internal) directive which will dump all the children of the fragment root node in its place. Since directives can manipulate DOM, we can act after rendering and bypass Vue limitation.
The component is called Fragment
so you won't have to change much code when Vue3 native fragments arrive. That said, I'm not a core developer of Vue.js, and I don't have any view of their implementation. I only know what fragments are and how they should work, and did my best to reproduce it ; so it should be fine.
npm i -s vue-fragment
From here, you can:
Plugin:
import Fragment from 'vue-fragment'
Vue.use(Fragment.Plugin)
// or
import { Plugin } from 'vue-fragment'
Vue.use(Plugin)
// …
export const MyComponent {
template: '
<fragment>
<input type="text" v-model="message">
<span>{{ message }}</span>
</fragment>
',
data() { return { message: 'hello world }}
}
Component:
import { Fragment } from 'vue-fragment'
export const MyComponent {
components: { Fragment },
template: '
<fragment>
<input type="text" v-model="message">
<span>{{ message }}</span>
</fragment>
',
data() { return { message: 'hello world }}
}
FAQs
fragment component for vuejs
The npm package vue-fragment receives a total of 19,122 weekly downloads. As such, vue-fragment popularity was classified as popular.
We found that vue-fragment demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.